﻿using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.CommonBot.POI;
using Styx.CommonBot.Profiles;
using Styx.CommonBot.AreaManagement;
using Styx.Pathing;
using Styx.Helpers;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Plugins;

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using Bots.DungeonBuddy.Helpers;
using System.Windows.Media;
using Styx.CommonBot.Routines;

namespace Guardian
{
    public partial class Combat : CombatRoutine
    {
        public void checkBuffs()
        {

            if (!buffExists(DEW_OF_ETERNAL_MORNING_BUFF, Me) && nextBuffAllowed <= DateTime.Now) //Dew of Eternal Morning
            {
                applyBuffs(103643);
            }
            if (!buffExists(BOOK_OF_THE_AGES_BUFF, Me) && nextBuffAllowed <= DateTime.Now) //Book of the Ages
            {
                applyBuffs(BOOK_OF_THE_AGES_ITEM);
            }
            if (!buffExists(SINGING_CRYSTAL_BUFF, Me) && nextBuffAllowed <= DateTime.Now) //Singing Crystal
            {
                applyBuffs(SINGING_CRYSTAL_ITEM);
            }
            if (!buffExists(WINDFEATHER_PLUME_BUFF, Me) && nextBuffAllowed <= DateTime.Now)
            {
                applyBuffs(WINDFEATHER_PLUME_ITEM);
            }
            if (Me.Combat
                && Me.CurrentTarget != null
                && Me.CurrentTarget.IsHostile
                && !buffExists(GLOWING_MUSHROOM_BUFF, Me)
                && nextBuffAllowed <= DateTime.Now)
            {
                applyBuffs(GLOWING_MUSHROOM_ITEM);
            }
            if (Me.Combat
                && Me.CurrentTarget != null
                && Me.CurrentTarget.IsHostile
                && nextBuffAllowed <= DateTime.Now)
            {
                dropBuffs(104335);
            }
            if (Me.Combat
                && Me.CurrentTarget != null
                && Me.CurrentTarget.IsHostile
                && nextBuffAllowed <= DateTime.Now)
            {
                dropBuffs(104334);
            }
            if (Me.Combat
                && Me.CurrentTarget != null
                && Me.CurrentTarget.IsHostile
                && nextBuffAllowed <= DateTime.Now)
            {
                dropBuffs(104336);
            }
            return;
        }
        public void applyBuffs(int buffName)
        {
            if (!buffExists(buffName, Me))
            {
                WoWItem potion = Me.BagItems.FirstOrDefault(h => h.Entry == buffName);

                if (potion == null)
                {
                    return;
                }
                if (potion != null && potion.CooldownTimeLeft.TotalMilliseconds <= 0)
                {
                    potion.Use();
                    Logging.Write(Colors.ForestGreen, "Using " + potion.Name);
                    SetNextBuffAllowed();
                }
            }
        }
        public void dropBuffs(int buffName)
        {
            if (!buffExists(buffName, Me))
            {
                WoWItem potion = Me.BagItems.FirstOrDefault(h => h.Entry == buffName);

                if (potion == null)
                {
                    return;
                }
                if (potion != null && potion.CooldownTimeLeft.TotalMilliseconds <= 0)
                {
                    potion.Use();
                    SpellManager.ClickRemoteLocation(Me.Location);
                    Logging.Write(Colors.ForestGreen, "Using " + potion.Name);
                    SetNextBuffAllowed();
                }
            }
        }
        public int SINGING_CRYSTAL_BUFF = 147055;
        public int SINGING_CRYSTAL_ITEM = 103641;
        public int DEW_OF_ETERNAL_MORNING_BUFF = 147476;
        public int DEW_OF_ETERNAL_MORNING_ITEM = 103643;
        public int BOOK_OF_THE_AGES_BUFF = 147226;
        public int BOOK_OF_THE_AGES_ITEM = 103642;
        public int WINDFEATHER_PLUME_BUFF = 148521;
        public int WINDFEATHER_PLUME_ITEM = 104287;
        public int GLOWING_MUSHROOM_ITEM = 104289;
        public int GLOWING_MUSHROOM_BUFF = 148525;
        public int GLOWING_HERB_ITEM = 104289;
        public int GLOWING_HERB_BUFF = 148525;
        public int WINTERFAL_FIREWATER_ITEM = 12820;
        public int WINTERFALL_FIREWATER_BUFF = 17038;
    }
}
